<template>
	<view class="wrap">
		<!-- 一行显示2个 -->
		<view class="wrap-row-list flex just-between" v-show="isRow">
			<block v-for="(item, index) in goodsList" :key="index">
				<view class="item" @click.stop="onDetail(item)">
					<view class="file">
						<image></image>
					</view>

					<view class="goods-name limit-1-line f-30">
						商品名称商品名称商品名称商品名称商品名称商品名称商品名称
					</view>
				</view>
			</block>
		</view>

		<view class="wrap-column-list" v-show="!isShow">
			<block v-for="(item, index) in goodsList" :key="index">
				<view
					class="item flex align-center"
					@click.stop="onDetail(item)"
				>
					<view class="file">
						<image></image>
					</view>

					<view class="right flex column just-between">
						<view class="goods-name limit-3-line f-30">
							商品名称商品名称商品名称商品名称商品名称商品名称商品名称
						</view>
					</view>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			/**
			 * 显示的样式
			 */
			isRow: {
				type: Boolean,
				default: false,
			},
			/**
			 * 数据
			 */
			goodsList: {
				type: Array,
				default: [],
			},
		},
		data() {
			return {};
		},
		methods: {
			/**
			 * 详情
			 */
			onDetail(item) {},
		},
	};
</script>

<style lang="scss" scoped>
	.wrap {
		padding: 20rpx 20rpx;
		width: 100%;
		box-sizing: border-box;
		overflow: hidden;
	}
	.wrap-row-list {
		width: 100%;
		overflow: hidden;
		flex-wrap: wrap;

		.item {
			width: calc(50% - 10rpx);
			padding: 20rpx;
			background-color: white;
			border-radius: 20rpx;
			box-sizing: border-box;
			margin-bottom: 20rpx;
			overflow: hidden;

			&:last-child {
				margin-bottom: 0rpx;
			}

			.file {
				width: 100%;
				height: auto;
				aspect-ratio: 1;
				background-color: red;

				> image {
					width: 100%;
					height: 100%;
				}
			}
		}
	}

	.wrap-column-list {
		width: 100%;
		overflow: hidden;

		.item {
			width: 100%;
			background-color: white;
			border-radius: 20rpx;
			box-sizing: border-box;
			margin-bottom: 20rpx;
			overflow: hidden;
			padding: 20rpx;

			&:last-child {
				margin-bottom: 0;
			}

			.file {
				width: 200rpx;
				height: 200rpx;
				background-color: red;
				border-radius: 10rpx;
				overflow: hidden;

				> image {
					width: 100%;
					height: 100%;
				}
			}

			.right {
				margin-left: 20rpx;
				min-height: 200rpx;
				flex: 1;
				overflow: hidden;

				.goods-name {
					margin-top: 10rpx;
					line-height: 1.5em;
				}
			}
		}
	}

	.goods-name {
		color: #333;
	}
</style>
